package com.zy.voteya.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author LiaoYan
 * @since 2025-09-20
 */
@Getter
@Setter
@ToString
public class Vote implements Serializable {

        private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @NotEmpty(message = "请输入投票题目")
    private String vname;

    @NotEmpty(message = "请输入投票类型")
    @Pattern(regexp = "单选|多选", message = "投票类型必须是'单选'或'多选'")
    private String vtype;

    @Future(message = "开始时间必须是未来的日期")
    private LocalDate startDate;

    @Future(message = "未来时间必须是未来的日期")
    private LocalDate endDate;

    @Size(min = 2, max = 5, message = "选项的数量必须是2~5个之间")
    @NotNull(message = "必须提交选项")
    @TableField(exist = false)  // 表示该属性不映射数据库字段
    private List<Items> items;
}
